#ifndef IMAMWAVE_H
#define IMAMWAVE_H

int inImamWave(void);

//Hardware Low Level Implementation : VIVO PASSTHRU
unsigned char ucImamVivoPtPing (void);
unsigned char ucImamVivoPtAntennaControl (unsigned char *AntCtrl);
unsigned char ucImamVivoPtLEDControl (unsigned char *LedCtrl);
unsigned char ucImamVivoPtBuzzControl (unsigned char *BuzzCtrl);
unsigned char ucImamVivoPtSetup (unsigned char *ucMode);
unsigned char ucImamVivoPtTokenPoll (unsigned char *ucTimeOut);
unsigned char ucImamVivoPtAPDU (unsigned char *ucAPDUcmd);
unsigned char ucImamVivoPtPCD (unsigned char *ucPCDcmd);
unsigned char ucImamVivoPtGetPCDparm (void);
unsigned char ucImamVivoPtHalt (unsigned char *ucHaltType);
unsigned char ucImamVivoPtMifareAuth (unsigned char *ucAuthData);
unsigned char ucImamVivoPtMifareRead (unsigned char *ucReadData, unsigned char *szHexBuff);
unsigned char ucImamVivoPtMifareWrite (unsigned char *ucWriteData);

int inImamVivoPtSaleOp_Req(unsigned long ulAmount, unsigned char *szHexTrxData);
int inImamVivoPtSaleTopupOp_Req(unsigned long ulAmount, unsigned char *szHexTrxData);
int inImamVivoPtMifareBalance(char *szBalance);
int inImamVivoPtMifareTrackData(char *szTrack2);
int inImamVivoPtSale (TRANSACTION_OBJECT *pobTran);
int inImamVivoPtSaleTopup (TRANSACTION_OBJECT *pobTran);
int inImamVivoPtMifareFunction (TRANSACTION_OBJECT *pobTran);


//GHL MIFARE
unsigned char ucImamGhlClearLine(unsigned char *szLine);
unsigned char ucImamGhlWriteLine(unsigned char *szLine);
unsigned char ucImamGhlBeep(unsigned char *szBeep);
unsigned char ucImamGhlGetReaderInfo(void);
unsigned char ucImamGhlInjectKey(unsigned char *szKey);
unsigned char ucImamGhlTurnOnRF(void);
unsigned char ucImamGhlTurnOffRF(void);
unsigned char ucImamGhlIsoReqA(void);
unsigned char ucImamGhlIsoWupa(void);
unsigned char ucImamGhlIsoAnticol(unsigned char *szLevel, unsigned char *szHexBuff);
unsigned char ucImamGhlIsoSelect(unsigned char *szLevel);
unsigned char ucImamGhlTokenPoll(int inTimeout, unsigned char *szSN);
unsigned char ucImamGhl3PassAuth(unsigned char *szKeyAndBlock, unsigned char *szSN, unsigned char *szKeyData);
unsigned char ucImamGhlMifareRead(unsigned char *szBlock, unsigned char *szHexBuff);
unsigned char ucImamGhlMifareWrite(unsigned char *szBlock, unsigned char *szBlockData);
unsigned char ucImamGhlMifareDecrement(unsigned char *szBlock, unsigned char *szValue);
unsigned char ucImamGhlMifareIncrement(unsigned char *szBlock, unsigned char *szValue);
unsigned char ucImamGhlMifareRestore(unsigned char *szBlock);
unsigned char ucImamGhlMifareTransfer(unsigned char *szBlock);
int inImamGhlMifareCommand(unsigned char *szCmd, unsigned char *szDataCmd, unsigned char *szHexCmdResult, unsigned char *szCmdResult);
int inImamMifareTimeOut(unsigned long TheTime);
extern void vdImamSaveCTLData (BATCH_REC *psrBRec, unsigned char * pszData);
extern int inImamGetCom1Device (void);
extern int inImamGetCom2Device (void);
int inInitComPortForWave(void);
int inEnableWaveReader(void);
int inImamCTLOfflineQualified(unsigned char *szHexBuff);
int inImamGetTag(unsigned char *szTag, int *inTagLen, unsigned char *szHexBuff, unsigned char *szValue);

//First Level Interface
int inImamContactlessSale (TRANSACTION_OBJECT *pobTran);
int inImamContactlessThanksWelcome(void);
int inImamInitContactlessParameter(void);
int inImamInitContactlessMessage(void);
int inImamInitContactlessCAPK(void);
int inImamReadContactlessParameter(void);

//Hardware High Level Interface
int inImamSaleVisaWave (TRANSACTION_OBJECT *pobTran);
int inImamInitVWaveParameter(void);
int inImamInitVWaveMessage(void);
int inImamInitVWaveCAPK(void);
int inImamReadVWaveParameter(void);

int inImamSaleVivotechPayPass (TRANSACTION_OBJECT *pobTran);
int inImamInitVivotechParameter(void);
int inImamInitVivotechMessage(void);
int inImamInitVivotechCAPK(void);
int inImamReadVivotechParameter(void);

//Hardware Low Level Implementation 1
int inImamVWaveSaleOp_Req(unsigned long ulAmount, unsigned char *szHexTrxData);
int inImamVWaveSaleOp_ShowStatus(void);
int inImamVWaveSaleOp_Reset(void);

int inImamVivoSaleOp_Req(unsigned long ulAmount, unsigned char *szHexTrxData);
int inImamVivoSaleOp_ShowStatus(void);
int inImamVivoSaleOp_Reset(void);

//Hardware Low Level Implementation : VIVOTECH
unsigned char ucImamVivoSetReaderPar (void);
unsigned char ucImamVivoSetPollMode (unsigned char *szMode);
unsigned char ucImamVivoGetTrxResult(void);
unsigned char ucImamVivoActivate(unsigned long ulAmount, unsigned char *szHexBuff);
unsigned char ucImamVivoGetLCD (unsigned char *szIndex);
unsigned char ucImamVivoStoreLCD (void);
unsigned char ucImamVivoSetLCD (unsigned char *szMsgId, unsigned char *szBeepId, unsigned char *szLEDnum, unsigned char *szLEDst);
unsigned char ucImamVivoGetEMVPar (void);
unsigned char ucImamVivoSetEMVPar (unsigned char *szTagValue);
unsigned char ucImamVivoCancelTransaction(void);
int inDisplayReaderResponseAndReturnAction(char ucResponse);
int inImamVivoCommand(unsigned char *szCmd, unsigned char *szDataCmd, unsigned char *szHexCmdResult, unsigned char *szCmdResult);
int inImamVivoCommandPassThru(unsigned char *szCmd, unsigned char *szDataCmd, unsigned char *szHexCmdResult, unsigned char *szCmdResult);

extern int inReadComPort(char *Recv, int inTimeOut);
extern int inWriteComPort(char *Sent, int inSentSize, int inTimeOut);
//Hardware Low Level Implementation : VISA WAVE
unsigned char ucImamVWavePoll(void);
unsigned char ucImamVWaveEcho(void);
unsigned char ucImamVWaveSetMode(unsigned char ucMode);
unsigned char ucImamVWaveSetParameter(unsigned char ucMode);

unsigned char ucImamGenMSES(void);
unsigned char ucImamGenASES(void);
unsigned char ucImamReplaceIMekIaek(void);
unsigned char ucImamDoMutualAuthProcess(void);
unsigned char ucImamDoMutualAuth(unsigned char ucKey);
unsigned char ucImamVWaveGenKeys(unsigned char ucKey);

unsigned char ucImamVWaveReadyForSale(unsigned long ulAmount, unsigned char *szHexBuff);
unsigned char ucImamVWaveTrxReset(void);
unsigned char ucImamVWaveShowStatus(unsigned char ucStatus);

unsigned char ucImamVWaveSetReaderPar(void);
unsigned char ucImamVWaveSetReaderMsg(void);
unsigned char ucImamVWaveSetReaderCAPK(void);
unsigned char ucImamVWaveGetReaderPar(void);
unsigned char ucImamVWaveAdminMode(unsigned char ucMode);
unsigned char ucImamVWaveGetCapability(void);
unsigned char ucImamVWaveSetCapability(unsigned char *szPaymentScheme);
unsigned char ucImamVWaveSyncTime(void);
unsigned char ucImamVWaveGetCAPK(unsigned char *szKeyIndex);
unsigned char ucImamVWaveSetCAPK(void);
unsigned char ucImamVWaveGetBaudRate(void);
unsigned char ucImamVWaveSetBaudRate(void);
unsigned char ucImamVWaveGetEMVTags(void);
unsigned char ucImamVWaveSetEMVTags(unsigned char *szTags);
unsigned char ucImamVWaveGetMessage(void);
unsigned char ucImamVWaveSetMessage(void);
unsigned char ucImamVWaveGetCVM(void);
unsigned char ucImamVWaveSetCVM(unsigned char *szCVMList);
int inImamVisaWaveCommandEnc(unsigned char ucMode, unsigned char ucCmd, unsigned char *szDataCmd, unsigned char *szHexCmdResult, unsigned char *szCmdResult);
int inImamVisaWaveCommand(unsigned char ucCmd, unsigned char *szDataCmd, unsigned char *szHexCmdResult, unsigned char *szCmdResult);

#define CMD_VW_POLL				0x07	//POLL Message
#define CMD_VW_ECHO				0x08
#define CMD_VW_SETMODE			0x10	//OPTIMIZATION Message
#define CMD_VW_SETPARM			0x12
#define	CMD_VW_INITCOMM			0x20	//SECURITY Message
#define CMD_VW_MAUTH			0x21
#define CMD_VW_GENKEY			0x22
#define CMD_VW_INVALIDE_READER	0x23	
#define CMD_VW_READY_SALE		0x30	//TRANSACTION Message
#define CMD_VW_RESET			0x31
#define CMD_VW_SHOW_STATUS		0x32
#define CMD_VW_SWITCH_ADMIN		0x40	//ADMINISTRATIVE Message (0x40-0x5B)

#define SCMD_SETMODE_OPTIMIZATION	0x00
#define SCMD_SETMODE_NORMAL			0x01

#define RC_SUCCESS					0x00  //SUCCESS Response
#define RC_DATA						0x01
#define RC_POLL_A					0x02
#define RC_POLL_P					0x03
#define RC_SCHEME_SUPPORTED			0x04
#define RC_SIGNATURE				0x05
#define	RC_ONLINE_PIN				0x06
#define RC_OFFLINE_PIN				0x07
#define RC_FAILURE					0xFF  //FAILURE Response
#define RC_ACCESS_NOT_PERFORMED		0xFE
#define RC_ACCESS_FAILURE			0xFD
#define RC_AUTH_FAILURE				0xFC
#define RC_AUTH_NOT_PERFORMED		0xFB
#define RC_DDA_AUTH_FAILURE			0xFA
#define RC_INVALID_COMMAND			0xF9
#define RC_INVALID_DATA				0xF8
#define RC_INVALID_PARAM			0xF7
#define RC_INVALID_KEYINDEX			0xF6
#define RC_INVALID_SCHEME			0xF5
#define RC_INAVALID_VISA_CA_KEY		0xF4
#define RC_MORE_CARDS				0xF3
#define RC_NO_CARD					0xF2
#define RC_NO_EMV_TAGS				0xF1
#define RC_NO_PARAMETER				0xF0
#define RC_POLL_N					0xEF
#define RC_OTHER_AP_CARDS			0xEE
#define RC_US_CARDS					0xED
#define RC_NO_PIN					0xEC
#define RC_NO_SIG					0xEB

#endif